/**
 * Created by zhushoude on 2017/5/18.
 */
var i = 1;
var totalPage = "";
$(function(){
    var token=localStorage.getItem("token");
    var src = tl_config.last_url;
    var i = src.indexOf('?');
     console.log(src);
    if(i!=-1) {
        var id = src.substring(i + 4);
        $("#demandId").val(id);
        gridObj = $.fn.bsgrid.init('g_tabYeh', {
            ajaxType: 'post',
            url: server_url + '/rest/demand/demandSuppyList.do?ran=' + Math.random() + '&token=' + token,
            otherParames: {'demandId': id},
            autoLoad: true,
            pageSizeSelect: true,
            stripeRows: true,
            pageSize: 10,
            displayBlankRows: false,
            isProcessLockScreen: true,
            rowSelectedColor: false,
            showPageToolbar: true,
            rowHoverColor: true
        });
    }


});
function operate(record, rowIndex, colIndex, options) {
    return '<a href="javascript:modifyDemandSupply(\'' + gridObj.getRecordIndexValue(record, 'id') + '\');">修改</a>'+
        '<a href="javascript:delDemandSupply(\'' + gridObj.getRecordIndexValue(record, 'id') + '\');">删除</a>';

};

function modifyDemandSupply(id) {
    var url='demand/modifyDemandSupply.do?id='+id;
    tl_config.loadToWorkArea(url);
}
function delDemandSupply(id) {
    if(empty(id)){
        easyDialog.open({
            container : {
                header : '温馨提示',
                content : '请选择要操作的记录！'
            },
            autoClose : 2000
        });
        return;
    }
    easyDialog.open({
        container : {
            header : '删除确认',
            content : '您确定要删除报价单么？',
            yesFn : function(){
                $.ajax({
                    url:server_url+'/rest/demand/delDemandSupply.do?ran='+Math.random()+"&token="+token,
                    type:'get',
                    data:{id:id},
                    success:function(data){
                        if(data.retCode=="0000"){
                            doSearch();
                        }
                        else{
                            easyDialog.open({
                                container : {
                                    header : '提示',
                                    content : data.retMsg
                                },
                                autoClose : 2000
                            });
                        }
                    }
                })
            },
            noFn : true
        }
    });
}




